package com.romotc.qqrobot.bean;

import java.io.IOException;
import java.sql.Timestamp;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;

import com.romotc.json.tools.Jackson;
import com.romotc.oschina.bean.POJO;
import com.romotc.qqrobot.webqq.bean.ContentFont;
import com.romotc.qqrobot.webqq.bean.Poll2_ResponseBody;
import com.romotc.qqrobot.webqq.bean.Poll2_ResponseBody_Result;
import com.romotc.qqrobot.webqq.bean.Poll2_ResponseBody_Result_Value;
/**
 * poll Poll2_ResponseBody_Result 返回消息对应的数据库对象
 * @author Administrator
 *
 */
public class PollResult extends POJO {
	/**
	 * 状态常量 已转发
	 */
	public static int Status_Forwarded = 1;
	
	/**
	 * 初始状态 未转发
	 */
	public static int Status_Default = 0;
	
	
	/**
	 * 发送消息的好友对应的客户id
	 */
	private long custId;
	/**
	 * 发送消息的好友对应的客服人员Id
	 */
	private long custServiceId;
	/**
	 * 该条消息的状态:0,未分发；1,已分发;2,已回复
	 */
	private int msgStatus;
	private Timestamp msgTime = new Timestamp(System.currentTimeMillis());
	
	
	//Poll2_ResponseBody   默认不填充 只有在没有result的时候才用于记录错误信息
	private int retcode;
	private String errmsg;
	private String p;
	
	//Poll2_ResponseBody_Result
	private String poll_type;
	
	//Poll2_ResponseBody_Result_Value
	private long msg_id;
	private long from_uin;
	private long to_uin;
	private long msg_id2;
	private int msg_type;
	private long reply_ip;
	private long time;
	private String contentMsg;
	private String font;
	private String mode;
	private int type;
	private String name;
	private long session_id;
	private long inet_ip;
	private int cancel_type;
	private int lc_id;
	
	private long uin;
	private String status;
	private int client_type;
	
	/**
	 * 根据Poll2_ResponseBody_Result 构造PollResult
	 * @param jsonResult
	 */
	public PollResult(Poll2_ResponseBody_Result jsonResult) {

		if(jsonResult != null)
			this.poll_type = jsonResult.getPoll_type();
		
		if(jsonResult.getValue() != null) {
			Poll2_ResponseBody_Result_Value value = jsonResult.getValue();
			this.msg_id = value.getMsg_id();
			this.from_uin = value.getFrom_uin();
			this.to_uin = value.getTo_uin();
			this.msg_id2 = value.getMsg_id2();
			this.msg_type = value.getMsg_type();
			this.reply_ip = value.getReply_ip();
			this.time = value.getTime();
			this.contentMsg = value.getContentMsg();
			this.font = value.getFontStr();
			this.mode = value.getMode();
			this.type = value.getType();
			this.name = value.getName();
			this.session_id = value.getSession_id();
			this.inet_ip = value.getInet_ip();
			this.cancel_type = value.getCancel_type();
			this.lc_id = value.getLc_id();
			
			//新增3个
			this.uin = value.getUin();
			status = value.getStatus();
			client_type = value.getClient_type();
			
		}
	}
	
	
	/**
	 *根据 消息体构建
	 * @param response
	 */
	public PollResult(Poll2_ResponseBody response) {
		if(response != null) {
			this.retcode = response.getRetcode();
			this.errmsg = response.getErrmsg();
			this.p = response.getP();
			
		}
	}
	
	public PollResult()
	{
		
	}
	
	
	public static void main(String[] args) {
		PollResult pollResult = new PollResult();
		pollResult.Save();
		
		pollResult = pollResult.Get(1L);
		System.out.println(pollResult.getId());
	}

	
	
	public long getCustId() {
		return custId;
	}

	public void setCustId(long custId) {
		this.custId = custId;
	}

	public long getCustServiceId() {
		return custServiceId;
	}

	public void setCustServiceId(long custServiceId) {
		this.custServiceId = custServiceId;
	}


	public int getMsgStatus() {
		return msgStatus;
	}


	public void setMsgStatus(int msgStatus) {
		this.msgStatus = msgStatus;
	}


	public long getUin() {
		return uin;
	}


	public void setUin(long uin) {
		this.uin = uin;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}


	public int getClient_type() {
		return client_type;
	}


	public void setClient_type(int client_type) {
		this.client_type = client_type;
	}


	public String getPoll_type() {
		return poll_type;
	}

	public void setPoll_type(String poll_type) {
		this.poll_type = poll_type;
	}

	public long getMsg_id() {
		return msg_id;
	}

	public void setMsg_id(long msg_id) {
		this.msg_id = msg_id;
	}

	public long getFrom_uin() {
		return from_uin;
	}

	public void setFrom_uin(long from_uin) {
		this.from_uin = from_uin;
	}

	public long getTo_uin() {
		return to_uin;
	}

	public void setTo_uin(long to_uin) {
		this.to_uin = to_uin;
	}

	public long getMsg_id2() {
		return msg_id2;
	}

	public void setMsg_id2(long msg_id2) {
		this.msg_id2 = msg_id2;
	}

	public int getMsg_type() {
		return msg_type;
	}

	public void setMsg_type(int msg_type) {
		this.msg_type = msg_type;
	}

	public long getReply_ip() {
		return reply_ip;
	}

	public void setReply_ip(long reply_ip) {
		this.reply_ip = reply_ip;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public String getContentMsg() {
		return contentMsg;
	}

	public void setContentMsg(String contentMsg) {
		this.contentMsg = contentMsg;
	}

	public String getFont() {
		return font;
	}

	public void setFont(String font) {
		this.font = font;
	}

	public String getMode() {
		return mode;
	}

	public void setMode(String mode) {
		this.mode = mode;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getSession_id() {
		return session_id;
	}

	public void setSession_id(long session_id) {
		this.session_id = session_id;
	}

	public long getInet_ip() {
		return inet_ip;
	}

	public void setInet_ip(long inet_ip) {
		this.inet_ip = inet_ip;
	}

	public int getCancel_type() {
		return cancel_type;
	}

	public void setCancel_type(int cancel_type) {
		this.cancel_type = cancel_type;
	}

	public int getLc_id() {
		return lc_id;
	}

	public void setLc_id(int lc_id) {
		this.lc_id = lc_id;
	}

	public int getRetcode() {
		return retcode;
	}

	public void setRetcode(int retcode) {
		this.retcode = retcode;
	}

	public String getErrmsg() {
		return errmsg;
	}

	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}

	public String getP() {
		return p;
	}

	public void setP(String p) {
		this.p = p;
	}


	public Timestamp getMsgTime() {
		return msgTime;
	}


	public void setMsgTime(Timestamp msgTime) {
		this.msgTime = msgTime;
	}
}